/*
 * @Description:测试同步
 * 
 * @Author: rendc
 * 
 * @Date: 2025-08-20 11:06:14
 * 
 * @LastEditors: rendc
 * 
 * @LastEditTime: 2025-08-20 11:14:19
 */
public class TestPrint {

  public static void main(String[] args) {
    // 创建MyPrint类的对象
    MyPrint myP = new MyPrint();
    // 同步功能在线程中体现
    // 创建线程 输出100次天天向上
    Thread t1 = new Thread() {
      @Override
      public void run() {
        for (int i = 0; i < 100; i++) {
          myP.print1();
          MyPrint.print3();
        }
      }
    };
    // 创建线程 输出100次好好学习
    Thread t2 = new Thread() {
      @Override
      public void run() {
        for (int i = 0; i < 100; i++) {
          myP.print2();
        }
      }
    };

    t1.start();
    t2.start();
  }
}